<template>
	<view class="accountSecurity">
		<u-navbar title="" height="120upx">
			<view class="u-nav-slot" slot="left">
				<view @tap="back" class="icon-left">
					<u-icon name="arrow-left" color="#000" size="20"></u-icon>
				</view>
			</view>
			<view class="u-nav-slot logoBox" slot="center">
				<view class="navBox">账户与安全</view>
			</view>
			<view class="u-nav-slot" slot="right">
				<view class="icon-right">
				</view>
			</view>
		</u-navbar>
		
		<view class="tab-list">
			<view class="list-item" v-for="(item,index) in tabList" :key="index" @tap="navTo(item,item.isLogin)">
				<view>
					<text>{{item.title}}</text>
				</view>
				<view>
					<text class="txt">{{item.text}}</text>
					<u-icon name="arrow-right" color="#999" size="30upx"></u-icon>
				</view>
			</view>
		</view>
		
<!-- 		<view class="tab-list">
			<view class="list-item" v-for="(item,index) in tabList1" :key="index" @tap="navTo(item,item.isLogin)">
				<view>
					<text>{{item.title}}</text>
				</view>
				<view>
					<u-icon name="arrow-right" color="#999" size="30upx"></u-icon>
				</view>
			</view>
		</view> -->
	</view>
</template>
<script>
	import {
	    mapState ,mapMutations
	} from 'vuex'; 
	export default {
		data() {
			return {
				message: false,
				tabList:[
					// {
					// 	title:'手机号',
					// 	path:'/pages/setting/modifyPhone',
					// 	isLogin:true,
					// 	text:""
					// },
					{
						title:'修改支付密码',
						path:'/pages/setting/updatePayPassword',
						isLogin:true,
						text:""
					},
					{
						title:'修改登录密码',
						path:'/pages/setting/updatePassword',
						isLogin:true,
						text:""
					},
				],
				tabList1:[
					{
						title:'账号注销',
						path:'/pages/setting/cancellationAccount',
						isLogin:true,
					},
				],
			}
		},
		computed:{
			...mapState(["hasLogin"]),
			uerInfo(){
			  let data = {};
			  if(this.$store.state.hasLogin && this.$store.state.uerInfo){
				data = this.$store.state.uerInfo;
				this.tabList = this.tabList.filter(item=>{
					if(item.title == "手机号"){
						let mobile = data.mobile;
						mobile = mobile.substring(0,3)+"****"+mobile.substring(7,11)
						item.text = mobile;
					}
					return item;
				});
				console.log(this.tabList)
			  }
			  return data;
			},
		},
		// onShow() {
		// 	if(this.uerInfo.isRealName == 0){
				
		// 		this.tabList.push({
		// 			title:'实名认证',
		// 			path:'/pages/openAccount/index',
		// 			isLogin:true,
		// 		})
		// 	}
		// },
		methods: {
			navTo(cur,flag){
				let url = cur.path;
				if(flag && !this.hasLogin){
					uni.navigateTo({
						url:"/pages/login/login"
					});
					return;
				}else if(cur.title == "实名认证" && this.uerInfo.isRealName == 0){
					url = url + `?phone=${this.uerInfo.mobile}`;
				}else if(cur.title == "实名认证" && this.uerInfo.isRealName == 1){
					url = `/pages/setting/account`;
				}else if((cur.title == "我的银行卡" || cur.title == "开户") && this.uerInfo.isRealName == 0){
					this.$u.toast('请先实名认证！');
					return;
				}
				uni.navigateTo({
					url:url
				});
			},
			back() {
				let canNavBack = getCurrentPages();
				if(canNavBack && canNavBack.length>1) {  
				    uni.navigateBack({  
				      delta: 1  
				    });  
				} else {  
				    history.back();  
				}
			}
		}
	}
</script>
<style lang="less" scoped>
	.accountSecurity {
		padding-top: 120upx;
		color:#333;
		.logoBox{
			width: 100%;
			height: 100%;
			.navBox{
				height: 120upx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #000;
				box-shadow: 0px 0px 1px 0px rgba(51, 51, 51, 0.5000);
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
			}
		}
		
		.tab-list{
			padding:2upx 30upx;
			background-color: #fff;
			margin-bottom: 20upx;
			font-size: 30upx;
			.list-item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 32upx;
				padding-bottom: 32upx;
				border-bottom: 2upx solid #F7F7F7;
				line-height: 30upx;
				font-weight: 400;
				height: 62upx;
				>view{
					display: flex;
					align-items: center;
					.txt{
						color: #999;
						margin-right: 16upx;
					}
				}
				.icon_img_right {
					// width: 24upx;
					height: 20upx;
				}
			}
			.list-item:last-child{
				border-bottom: 0;
			}
		}
	}
</style>
